<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title> - 基本表单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改课程</h5>

                </div>
                <div class="ibox-content">
                    <div id="form" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">课程名称</label>

                            <div class="col-sm-10">
                                <input type="text"  name="name" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上课地点</label>

                            <div class="col-sm-10">
                                <input type="text"  name="didian" class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上课时间</label>
                            <div class="col-sm-10">
                                <input type="text" name="shijian" class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">课程内容</label>
                            <div class="col-sm-10">
                                <textarea rows="5" name="neirong" class="form-control"></textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">课程周期</label>
                            <div class="col-sm-10">
                                <input type="text" name="zhouqi" class="form-control">
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上传封面</label>
                            <div class="col-sm-10">
                                <img onclick="uptu.up(this)" id="fengmian" src="img/addimg.jpg" style="height: 150px;width: 200px;border: 1px solid black;margin-top: 20px;">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button onclick="xinzeng()" class="btn btn-primary">确认修改</button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div style="display: none">
    <input onchange="uptu.tupian(this)" id="tu" accept="image/*" name="img" type="file">
</div>


<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<script src="chajian/node_modules/lrz/dist/lrz.all.bundle.js"></script>
<script src="js/uptu.js"></script>
<script src="chajian/jqueryform.js"></script>
<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>
<script src="js/zhangyue5.4.js"></script>
<script>

    const kid = window.location.href.split('kid=')[1];
    if(!kid || kid==""){
        window.location.href='kecheng_list.html';
    }

    shuju.set('kid',kid);
    shuju.set('method','detail');
    shuju.getshuju('kecheng',{
        success:function(data){
            if(data.code==200){
                let info = data.data;
                let input = ipt.getshuru('form','all');
                ipt.setinput(input).setall(info,'json');
                document.getElementById('fengmian').src=info.fengmian;
                document.getElementById('fengmian').setAttribute('data-src',info.fengmian);
            }
        },
        error:function(e){

        }
    });
    const uptu = new UpTu();
    const xinzeng = function(){
        const input = ipt.getshuru('form','all');
        if(ipt.checkinput(input)){
            let nr = ZY.MaptoJson(ipt.gettext(input));
            let fengmian = document.getElementById('fengmian');
            if(!fengmian.dataset.src){
                toastr.error('请先上传图片','系统提示');
                return;
            }
            for(let key in nr){
                shuju.set(key,nr[key]);
            }
            shuju.set('fengmian',fengmian.dataset.src);
            shuju.set('kid',kid);
            shuju.set('method','bianji');
            shuju.getshuju('kecheng',{
                success:function(data){
                    if(data.code==200){
                        toastr.success('编辑成功','系统提示');
                        setTimeout(function(){
                            window.location.href='kecheng_list.html';
                        },2000);
                    }else{
                        toastr.error('错误','系统提示');
                    }
                },
                error:function(e){
                    toastr.error('网络错误','系统提示');
                }
            })
        }
    }

</script>
</body>

</html>